var app = angular.module('app');

app.factory('timeValidateService', [function () {
    var timeValidateService = {};

    timeValidateService.isClockValid = function (value) {
        if (!value || value.length == 0) {
            return true;
        }
        var timeArray = value.split(':');
        if (timeArray.length != 2) {
            return false;
        }
        var hourString = timeArray[0];
        if (hourString.length != 2) {
            return false;
        }
        var hour = parseInt(hourString);
        if (hour < 0 || hour > 24) {
            return false;
        }
        var minuteString = timeArray[1];
        if (minuteString.length != 2) {
            return false;
        }
        var minute = parseInt(minuteString);
        if (minute < 0 || minute > 60) {
            return false;
        }
        return true;
    };

    return timeValidateService;
}]);